﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace TankBattle.Models
{
    public class ControllerTank: Tank
    {
        #region Contruction

        public ControllerTank()
        { }
        public ControllerTank(Texture2D texture, Vector2 position)
        {
            Intallization(texture, position,
                Constant.TANK_SIZE_WIDTH, Constant.TANK_SIZE_HEIGHT);
        }
        public ControllerTank(Texture2D texture, Vector2 position, int width, int height, int flag)
            : base(texture, position, width, height, flag)
        { }

        #endregion

        #region Function 
        //Update (override) cập nhật trạng thái di chuyển khi nhấn phím.
        public override bool Update()
        {
            KeyboardState keyboard = Keyboard.GetState();

            if (keyboard.IsKeyDown(Keys.Down))
                flag = Constant.MOVE_DOWN;
            else if (keyboard.IsKeyDown(Keys.Up)) 
                flag = Constant.MOVE_UP;
            else if (keyboard.IsKeyDown(Keys.Left))
                flag = Constant.MOVE_LEFT;
            else if (keyboard.IsKeyDown(Keys.Right)) 
                flag = Constant.MOVE_RIGHT;

            else flag = Constant.ZERO;

            return base.Update();
        }
        #endregion
    }
}
